package tech.xs.common.framework.util;

import cn.hutool.core.util.StrUtil;
import tech.xs.common.framework.domain.enums.ApiResultEnum;
import tech.xs.common.framework.domain.exception.BusinessException;

public class Assert {

    public static void isTrue(boolean expression, String message) {
        if (!expression) {
            throw new BusinessException(message);
        }
    }

    public static void isTrue(boolean expression, String message, boolean isPrint) {
        if (!expression) {
            throw new BusinessException(message, isPrint);
        }
    }

    public static void isTrue(boolean expression, Integer code, String message) {
        if (!expression) {
            throw new BusinessException(code, message);
        }
    }

    public static void isTrue(boolean expression, Integer code, String message, boolean isPrint) {
        if (!expression) {
            throw new BusinessException(code, message, isPrint);
        }
    }

    public static void isTrue(boolean expression, ApiResultEnum result) {
        if (!expression) {
            throw new BusinessException(result);
        }
    }

    public static void isTrue(boolean expression, ApiResultEnum result, boolean isPrint) {
        if (!expression) {
            throw new BusinessException(result, isPrint);
        }
    }

    public static void isFalse(boolean expression, String message) {
        if (expression) {
            throw new BusinessException(message);
        }
    }

    public static void isFalse(boolean expression, String message, boolean isPrint) {
        if (expression) {
            throw new BusinessException(message, isPrint);
        }
    }

    public static void isFalse(boolean expression, Integer code, String message) {
        if (expression) {
            throw new BusinessException(code, message);
        }
    }

    public static void isFalse(boolean expression, Integer code, String message, boolean isPrint) {
        if (expression) {
            throw new BusinessException(code, message, isPrint);
        }
    }

    public static void isFalse(boolean expression, ApiResultEnum result) {
        if (expression) {
            throw new BusinessException(result);
        }
    }

    public static void isFalse(boolean expression, ApiResultEnum result, boolean isPrint) {
        if (expression) {
            throw new BusinessException(result, isPrint);
        }
    }

    public static void isBlank(String str, String message) {
        if (!StrUtil.isBlank(str)) {
            throw new BusinessException(message);
        }
    }

    public static void isBlank(String str, String message, boolean isPrint) {
        if (!StrUtil.isBlank(str)) {
            throw new BusinessException(message, isPrint);
        }
    }

    public static void isBlank(String str, Integer code, String message) {
        if (!StrUtil.isBlank(str)) {
            throw new BusinessException(code, message);
        }
    }

    public static void isBlank(String str, Integer code, String message, boolean isPrint) {
        if (!StrUtil.isBlank(str)) {
            throw new BusinessException(code, message, isPrint);
        }
    }

    public static void isBlank(String str, ApiResultEnum result) {
        if (!StrUtil.isBlank(str)) {
            throw new BusinessException(result);
        }
    }

    public static void isBlank(String str, ApiResultEnum result, boolean isPrint) {
        if (!StrUtil.isBlank(str)) {
            throw new BusinessException(result, isPrint);
        }
    }

    public static void isNotBlank(String str, String message) {
        if (!StrUtil.isNotBlank(str)) {
            throw new BusinessException(message);
        }
    }

    public static void isNotBlank(String str, String message, boolean isPrint) {
        if (!StrUtil.isNotBlank(str)) {
            throw new BusinessException(message, isPrint);
        }
    }

    public static void isNotBlank(String str, Integer code, String message) {
        if (!StrUtil.isNotBlank(str)) {
            throw new BusinessException(code, message);
        }
    }

    public static void isNotBlank(String str, Integer code, String message, boolean isPrint) {
        if (!StrUtil.isNotBlank(str)) {
            throw new BusinessException(code, message, isPrint);
        }
    }

    public static void isNotBlank(String str, ApiResultEnum result) {
        if (!StrUtil.isNotBlank(str)) {
            throw new BusinessException(result);
        }
    }

    public static void isNotBlank(String str, ApiResultEnum result, boolean isPrint) {
        if (!StrUtil.isNotBlank(str)) {
            throw new BusinessException(result, isPrint);
        }
    }

    public static void isNull(Object obj, String message) {
        if (null != obj) {
            throw new BusinessException(message);
        }
    }

    public static void isNull(Object obj, String message, boolean isPrint) {
        if (null != obj) {
            throw new BusinessException(message, isPrint);
        }
    }

    public static void isNull(Object obj, Integer code, String message) {
        if (null != obj) {
            throw new BusinessException(code, message);
        }
    }

    public static void isNull(Object obj, Integer code, String message, boolean isPrint) {
        if (null != obj) {
            throw new BusinessException(code, message, isPrint);
        }
    }

    public static void isNull(Object obj, ApiResultEnum result) {
        if (null != obj) {
            throw new BusinessException(result);
        }
    }

    public static void isNull(Object obj, ApiResultEnum result, boolean isPrint) {
        if (null != obj) {
            throw new BusinessException(result, isPrint);
        }
    }


    public static void isNotNull(Object obj, String message) {
        if (obj == null) {
            throw new BusinessException(message);
        }
    }

    public static void isNotNull(Object obj, String message, boolean isPrint) {
        if (obj == null) {
            throw new BusinessException(message, isPrint);
        }
    }

    public static void isNotNull(Object obj, Integer code, String message) {
        if (obj == null) {
            throw new BusinessException(code, message);
        }
    }

    public static void isNotNull(Object obj, Integer code, String message, boolean isPrint) {
        if (obj == null) {
            throw new BusinessException(code, message, isPrint);
        }
    }

    public static void isNotNull(Object obj, ApiResultEnum result) {
        if (obj == null) {
            throw new BusinessException(result);
        }
    }

    public static void isNotNull(Object obj, ApiResultEnum result, boolean isPrint) {
        if (obj == null) {
            throw new BusinessException(result, isPrint);
        }
    }

}
